import { createWebHistory, createRouter } from 'vue-router'
import Layout from '@/layout/index.vue'
import { constantRoutes } from './modules/routers'

const routes = [
  { path: '/', name: 'layout', component: Layout, children: constantRoutes },
  { path: '/:pathMatch(.*)*', redirect: { name: 'home' } },
]

const router = createRouter({
  history: createWebHistory(),
  routes,
})

router.beforeEach((to, from, next) => {
  next()
})

export default router
